import { IPSApplication } from '../ipsapplication';
import { IPSAppDEField } from '../dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppWF } from './ipsapp-wf';
import { IPSAppWFDE } from './ipsapp-wfde';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppWFDEImpl extends PSModelObjectImpl implements IPSAppWFDE {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get entityWFState(): string {
    return this.M.entityWFState;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdataentity: IPSAppDataEntity | null = null;

  getPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.psappdataentity != null) return this.psappdataentity;
    const value = this.M.getPSAppDataEntity;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappdataentity = ipsapplication.findPSAppDataEntity(value);
    }
    return this.psappdataentity;
  }

  get psAppDataEntity(): IPSAppDataEntity | null {
    return this.getPSAppDataEntity();
  }

  getPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定应用实体');
    }
    return value;
  }

  protected psappwf: IPSAppWF | null = null;

  getPSAppWF(): IPSAppWF | null {
    if (this.psappwf != null) return this.psappwf;
    const value = this.M.getPSAppWF;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappwf = ipsapplication.findPSAppWF(value);
    }
    return this.psappwf;
  }

  get psAppWF(): IPSAppWF | null {
    return this.getPSAppWF();
  }

  getPSAppWFMust(): IPSAppWF {
    const value = this.getPSAppWF();
    if (value == null) {
      throw new Error('未指定应用工作流');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  protected wfstatepsappdefield: IPSAppDEField | null = null;

  getWFStatePSAppDEField(): IPSAppDEField | null {
    if (this.wfstatepsappdefield != null) return this.wfstatepsappdefield;
    const value = this.M.getWFStatePSAppDEField;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.wfstatepsappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.wfstatepsappdefield;
  }

  get wFStatePSAppDEField(): IPSAppDEField | null {
    return this.getWFStatePSAppDEField();
  }

  getWFStatePSAppDEFieldMust(): IPSAppDEField {
    const value = this.getWFStatePSAppDEField();
    if (value == null) {
      throw new Error('未指定流程状态应用应用属性');
    }
    return value;
  }

  get cls(): string {
    return 'PSAppWFDEImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.wf.IPSAppWFDE') return true;
    return super.instanceof(cls);
  }
}
